package day4;

import java.lang.reflect.Array;
import java.util.Arrays;

public class demo6 {
    public static void main(String[] args) {
        demo3();
    }
    public static void demo1() {
        int[] nums = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        //数组不是原生类
        //显示在堆内存中保存的地址
        System.out.println(nums);
        String result= Arrays.toString(nums);
        System.out.println(result);
    }
    public static void demo2() {
        int[] nums = {1, 8, 7, 4, 1, 9, 7, 4, 9, 10};
        System.out.println(Arrays.toString(nums));
        Arrays.sort(nums);//升序
        System.out.println(Arrays.toString(nums));
    }

    public static void demo3() {
        int[] nums = {5, 2, 6, 4, 2, 6, 1, 7, 4, 6};
        System.out.println(Arrays.toString(nums));
        for (int i = 0; i < nums.length-1; i++) {
            for (int j = 0; j < nums.length-i-1; j++) {
                if (nums[j] > nums[j+1]) {
                    int temp = nums[j];
                    nums[j] = nums[j+1];
                    nums[j+1] = temp;
                }
            }
        }
        System.out.println(Arrays.toString(nums));
    }
}